package com.itheima01;

public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr = new int[3];
        System.out.println(arr); //[I@1b6d3586
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);

        arr[0] = 100;
        arr[2] = 200;
        System.out.println(arr); //[I@1b6d3586
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);

        System.out.println("---------------------------");
        int[] arr1 = arr;
        arr1[0] = 300;
        System.out.println(arr); //[I@1b6d3586
        System.out.println(arr1);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);

        System.out.println("----------静态初始化---------");
        int[] arr2 = {1, 2, 3};
        System.out.println(arr2);
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);
        System.out.println(arr2[2]);

        System.out.println("----------常见问题：--------");
        System.out.println("----------越界与空指针：--------");
//        System.out.println(arr2[3]);
//        System.out.println(arr[3]);//ArrayIndexOutOfBoundsException
        arr2 = null;
//        System.out.println(arr2[0]);//NullPointerException

        System.out.println("数组常见操作：---------------");
        System.out.println(arr.length);
    }
}
